home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
art&graf.ix
/
art-3411
/
kraska
/
kraska.doc
< prev
next >
Wrap
Text File
|
1992-01-26
|
17KB
|
386 lines
KRASKA v1.2
¯¯¯¯¯¯¯¯¯¯¯
by Robert Samuel
48 Caie Walk
Bury St. Edmunds
Suffolk
IP33 2NZ
KRASKA is my attempt at writing a fractal graphics program. It's not the
first of it's kind, and I'm sure it won't be the last, but it does have one or
two features that make it unique, as far as I know. The program is freeware -
I don't want any money from anyone for it, but it would be nice to hear
feedback from anybody who uses it. All constructive criticism and suggestions
for improvement are welcome!
Why KRASKA? Well, 'kraska' is the Russian for 'colour', an appropriate name
for a program of this type. Why Russian? I just happened to have a Russian
dictionary handy when I was trying to think of an original name for it....
The program was written on a 1040 STFM in GFA Basic v3.5 using Hisoft's
WERCS to construct the resource. It should be able to use all 4096 colours of
the STE's palette, but I'm afraid I haven't been able to test this.
You should have the following files on this disk:
KRASKA.PRG The program
KRASKA.RSC It's resource file
KRASKA.DOC The manual
KRASKA.GFA The GFA 3.5 source code
A selection of pictures in Degas PI* format with corresponding KPR parameter
files
Of these, only the program and it's resource are necessary to use it. Any
others are created as needed by KRASKA.
A full understanding of how the program works and what the different
fractal types actually mean needs an understanding of complex number theory.
This is a subject that has been covered in the ST magazines in the past (e.g.
ST FORMAT 28, November 1991), but is summarised briefly in the Appendix A. An
appreciation of the theory will help you to understand the relationship between
the parameters that KRASKA uses and the final picture produced.
Using KRASKA
¯¯¯¯¯¯¯¯¯¯¯¯
KRASKA uses a conventional GEM menu bar/dialogue box interface. It will run
from any folder on floppy or hard disk, the only restriction being that the
program and resource file are in the same folder. It runs in all three
resolutions, and although the prettiest are undoubtedly those produced in low
resolution, the high res mode does have something to offer.
Double clicking on KRASKA.PRG loads the program, sets the default
parameters, and displays an introductory dialogue box on screen. Clicking
anywhere on the screen or pressing any key then clears the screen and displays
the menu bar with the headings Desk, File, Type, Edit, and Action. The menu
entries are discussed below.
Desk
¯¯¯¯
About
Displays the introductory dialogue box. Press any key or click mouse to
clear it.
File
¯¯¯¯
Load parameters
KRASKA stores picture parameters in a file with the extension .KPR.
Selecting this option displays an alert box asking if you wish to replace the
current parameters. If you confirm this, the file selector appears displaying
the .KPR files in the current directory. Selecting one of these loads the
parameters into memory.
Save parameters
Saves the current parameters as a .KPR file
Load picture
Loads and displays a Degas .PI1, .PI2, or .PI3 picture (depending on
resolution). The associated parameter file (which should have the same name,
but extension .KPR) is also loaded. An alert box appears if the parameter file
can't be found.
Save picture
Saves a picture in Degas format along with the parameter file. For
example, saving a picture as "EXAMPLE1.PI1" would save the parameters in
"EXAMPLE1.KPR".
Delete file
Allows the deletion of any file. An alert box appears asking you to confirm
the deletion after a file has been selected.
Quit
An alert box asks if you are sure you want to leave KRASKA. Click on Yes to
exit the program.
Type
¯¯¯¯
KRASKA can create pictures using 12 different formulae. The required
fractal type is selected by clicking on the type - a tick by the type shows
which is selected.
The different types are listed below, and described more fully in Appendix
B.
1 Mandelbrot
2 3rd order Mandelbrot
3 4th Order Mandelbrot
4 Julia
5 3rd order Julia
6 Type 2 Julia
7 Logarithmic
8 3rd Order Newton
9 Sine 1
10 Sine 2
11 Sine 3
12 Sine 4
Types 1 and 4 are the standard Mandelbrot and Julia patterns found in most
fractal graphics programs. Types 2,3,5 and 6 are mathematically related to
these, but give different kinds of pictures. The remaining types use
appreciably different formulae to generate patterns, and it should be noted
that because of the greater mathematical and computational complexity of these
types, they do take a little longer to draw.
Edit
¯¯¯¯
Edit parameters
A dialogue box appears displaying the parameters used by KRASKA to generate
pictures. Those not relevant to the current fractal type (previously selected
from the Type menu) are disabled. The parameters are:
Seed: Real part
Imaginary part
Maximum number of iterations
Iteration radius
Iteration limit
Top left x,y
Lower right x,y
See Appendix B for details.
The last pair of parameters, width and height of draw area, are the size in
pixels of the box within which the picture will be drawn. The default values
will draw a full screen picture. The minimum size allowed is 10 x 10, the
maximum is full screen. Values entered outside these ranges will be adjusted.
Using small values, say 50 x 50, is a useful way of previewing a picture before
starting a full scale drawing.
Once you've entered the required values for these parameters, click on one
of the exit buttons:
Cancel
Clears the dialogue box and leaves parameters unchanged.
Accept
Clears the dialogue box and replaces the current parameters with those
entered in the box.
To KRK
KRASKA has the facility to store a series of picture parameters in an
autorun file, KRASKA.KRK. Selecting Draw from the Action menu with the autorun
option active causes KRASKA to take its parameters from the autorun file, draw
the picture, save it, and move on to the next set of parameters. This allows
unattended operation of the program, overnight for instance, which is useful
since some of the more complex fractal types can take hours to complete a
picture, particularly in high resolution. Selecting To KRK brings up an alert
box asking whether you want to replace the existing autorun file or to append
the current parameters to it.
Set defaults
Replaces the current parameters with KRASKA's default parameters.
Palette 1
KRASKA has five built-in palettes which are selected by the Palette menu
items - the default on loading KRASKA is Palette 1. If the picture you've just
drawn doesn't look too clear, try changing the palette. It can make quite a
difference!
Action
¯¯¯¯¯¯
Draw
Draws a picture using the current parameters. The process can be
interrupted at any time by pressing any key. An alert boxes then appears asking
if you really want to abort the drawing, or if you'd like to continue.
When the picture is complete, another alert box appears showing the time taken
to draw the picture. Clicking on Ok then leaves the completed picture on
screen.
Show pic
Removes the menu bar allowing you to see the completed picture in its
entirety. Clicking a mouse button restores the menu bar.
Zoom
Using the Zoom function you can close in on any interesting looking portion
of a curve. Position the mouse cursor at the top left corner of the area of
interest, hold the left button down and drag the mouse until the required area
is enclosed. A box is drawn showing the selected area and the coordinates of
the draw area are updated. Selecting Draw will then plot the new picture.
Auto run
One of the nice features of KRASKA is its ability to automatically draw and
save a series of pictures according to a preset series of parameters - see To
KRK. Selecting Autorun activates the Autosave option and reads in the first set
of parameters that has previously been saved in KRASKA.KRK. The program then
draws the picture, saves it and its parameter file to disk, and loads in the
next set of parameters. This process continues until all sets of parameters
have been drawn. If you've chosen to keep a log, then this too will be
updated.
Autosave
Selecting Autosave causes KRASKA to automatically save a completed picture
to disk along with its associated parameter file. See Appendix C for details of
the file naming convention used by the program.
Cycle
Cycle randomly changes the colour palette. This produces some interesting
effects, but is otherwise pretty useless! (See Reset palette)
Clear
Clears the screen.
Keep log
Updates a file called KRASKA.LOG (or creates it if one does not exist) each
time a picture is drawn. The file includes information on the fractal type, its
parameters, the time and date it was saved to disk, and the time it took to
draw. The file is in ASCII format.
Appendix A
¯¯¯¯¯¯¯¯¯¯
Complex Numbers
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Ordinary numbers such as 1, -1.4, SQR(5), and PI are "real" numbers, and
can be thought of as distances measured along a straight horizontal line from a
zero point, or "origin". Positive numbers lie to the right of the origin,
negative numbers to the left. Suppose we now construct a line perpendicular to
the first line, but still passing through the origin. We can measure distances
along this line from the origin, but now in a vertical direction - what does
this mean?
Let's go back to the real numbers. Think now of a number as a vector i.e.
as a quantity that has both magnitude (length) and direction (0 or 360 degrees
for positive numbers, 180 or -180 degrees for negative numbers). If we halve
the angles for a positive number we get 0 and 180 degrees - in other words
positive and negative numbers. Now a positive number has two square roots, the
same size but with different signs, so perhaps halving the angle is equivalent
to taking a square root? A negative number conventionally doesn't have a square
root, but if we halve the angles for a negative number we get 90 and -90
degrees, equivalent to moving along the vertical line. So a distance of 1 along
the vertical line is equivalent to SQR(-1). This quantity is denoted by i, and
has the following properties:
1*i = i
i*i = -1
-1*i = -i
-i*i = 1
i.e. multiplying by i is equivalent to rotating the vector through 90 degrees
anti-clockwise. Distances along the vertical line therefore represent multiples
of i, and are known as "imaginary" numbers. A distance of 2 units above the
origin would be 2i, 3 units below the origin is -3i.
Let's now extend the idea a little further. What happens if the point lies
on neither of the lines, but elsewhere on the plane containing the two lines?
This point would require two numbers to define its position on the plane (just
like longitude and latitude). In our case the number would be represented by a
combination of a real and an imaginary number. For example 3-2i would be a
number 3 units to the right of the origin and 2 units below. Such a number is
known as a "complex" number.
Complex numbers can be added, subtracted, multiplied and divided in the
same way as ordinary numbers can, using the rules defined above for i:
(a+bi)+(c+di)=(a+c)+(b+d)i
(a+bi)-(c+di)=(a-c)+(b-d)i
(a+bi)*(c+di)=a*(c+di)+bi*(c+di)
=(a*c)+(a*d*i)+(b*c*i)+(b*d*i*i)
=(ac-bd)+(ad+bc)i
(a+bi) (a+bi)*(c-di) (ac+bd)+(bc-ad)i
------ = ------------- = ----------------
(c+di) (c+di)*(c-di) c^2+d^2
Other mathematical operations, such as sin, log, exp can also be applied to
complex numbers, though the detail is too complicated to go into here.
To go back to the idea of a number as a vector, it can be seen that a real
number is just a special case of a complex number. The general complex number
has a distance from the origin (known as the modulus) and a direction measured
anti-clockwise from the positive real direction (known as the argument). For a
complex number x+yi (denoted by z)
Modulus: mod(z) = SQR(x^2+y^2)
Argument: arg(z) = ATN(y/x)
Multiplication and division of complex numbers can now be thought of as
combining the moduli and arguments of the numbers:
mod(z1*z2) = mod(z1) * mod(z2) mod(z1/z2) = mod(z1) / mod(z2)
arg(z1*z2) = arg(z1) + arg(z2) arg(z1/z2) = arg(z1) - arg(z2)
The concept of modulus is important in the theory of fractals (see Appendix
B)
Appendix B
¯¯¯¯¯¯¯¯¯¯
KRASKA's fractal types
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
In the following explanation of KRASKA's fractal types, the following
variables are used:
w The complex number equivalent to the coordinates of the point
being calculated.
z(N) The Nth iteration of a calculation sequence.
R The iteratiion radius.
L The iteration limit.
Nmax The maximum number of iterations before the iteration
terminates.
c Seed.
Mandelbrot types:
Mandelbrot z(N+1)=z(N)^2+w z(0)=0
3rd order Mandelbrot z(N+1)=z(N)^3+w z(0)=0
4th order Mandelbrot z(N+1)=z(N)^4+w z(0)=0
Iteration continues until N>Nmax or mod(z(N))>R.
Julia types:
Julia z(N+1)=z(N)^2+c z(0)=w
3rd order Julia z(N+1)=z(N)^3+c z(0)=w
Type 2 Julia z(N+1)=c*(z(N)^2)+1) z(0)=w
Iteration continues until N>Nmax or mod(z(N))>R.
Logarithmic type:
z(N+1)=z(N)*log(z(N))+c z(0)=w
Iteration continues until N>Nmax or mod(z(N))>R.
Newton type:
Uses the Newton-Raphson iterative method to solve the equation z^3=c.
z(0)=w. Iteration continues until N>Nmax or mod(z(n)-z(n-1))<L.
Sine types:
Type 1 z(N+1)=sin(z(N)+c) z(0)=w
Type 2 z(N+1)=sin(z(N)+c)+w z(0)=w
Type 3 z(N+1)=c*sin(z(N)) z(0)=w
Type 4 z(N+1)=z*sin(z(N))+c z(0)=w
Iteration continues until N>Nmax or mod(z(N))>R.
Appendix C
¯¯¯¯¯¯¯¯¯¯
KRASKA's file naming convention
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Picture filenames used by KRASKA if the autosave option is selected are of
the following form:
XXXXXRNN.EXT
The first five charcters of the filename show the fractal type:
MANDL Mandelbrot
MAND3 Third order Mandelbrot
MAND4 Fourth order Mandelbrot
JULIA Julia
JULI3 Third order Julia
JULI2 Julia type 2
LOGAR Logarithmic
NEWT3 Third order Newton
SINE1 Sine type 1
SINE2 Sine type 2
SINE3 Sine type 3
SINE4 Sine type 4
The next character indicates the picture resolution:
0 Low resolution
1 Medium resolution
2 High resolution
The extension shows the file type:
PI1 Low resolution Degas file
PI2 Medium resolution Degas file
PI3 High resolution Degas file
KPR KRASKA parameter file
26th January 1992.